/*
                    CursorEngine Class Definition
*/

#ifndef CURSORENGINE_H
#define CURSORENGINE_H

#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include <vector>
#include <string>

#include "../Structs.h"
#include "Cursor.h"
#include "../GUISystem/Label.h"
#include "../ConfigFile.h"
#include "MouseContextMenu.h"

using namespace std;

class CursorEngine
{
    public:
        ~CursorEngine() {}

        static void FreeCursors();

        static int parseInput(const SDL_Event& event);

        static int Initialise();

        static int AddCursor(const string& strNewName, const string& strFilepath, const Point& Focus, const string& strFilepath_c = "");
        static int SetActiveCursor(const string& strName);

        static int BlitToScreen(SDL_Surface *screen);

        static void setPosition(const Point& NewPosition);
        static void setPosition(const double& nx, const double& ny);
        static Point getPosition();

        static void StartDragging(SDL_Surface* NewDraggingImage, vector<string> strNewDraggingData, Point NewDraggingOffset);
        static void StopDragging();
        static void ClearDraggingData();

        static SDL_Surface* getDraggingImage();
        static vector<string>& getDraggingData();
        static Point getDraggingOffset();

        static void ShowTooltip(const string& strTooltip);
        static void HideTooltip();

        static void AddContextMenu(const string& strName, const vector<string>& Items);
        static void OpenContextMenu(const string& strName, const string& strMenuData);

    private:
        CursorEngine() {}

        static Point Position;

        static Label lblTooltip;

        static bool bActiveCursor;
        static bool bWasOutside;
        static bool bMouseDown;

        static vector<Cursor*> Cursors;

        static string strActiveCursor;

        static SDL_Surface* DraggingImage;

        static Point DraggingOffset;

        static vector<string> strDraggingData;

        static vector<MouseContextMenu*> ContextMenus;
        static MouseContextMenu *currentContextMenu;

        static bool bDragging;

        static bool bShowTooltip;
        static bool bContextMenuOpened;

        static int MoveRelative(const double& nx, const double& ny);
        static int GetCursorByName(const string& strName);

        static int HandleMouseMotion(const int& iMouseXREL, const int& iMouseYREL);

        static void HandleContextMenuClick(const string& strName, const string& strSelected, const string& strMenuData);
};

#endif
